#pragma once
#include "DMatrix3.h"
#include "DVector3.h"
#include "DVector4.h"
#include "DQuaternion.h"

namespace Skill
{
	namespace Ode
	{		
		void DMatrix3::CollectManagedMemory()
		{
		}

		dReal DMatrix3::default::get(int index)
		{
			return _This[index];			
		}
		void DMatrix3::default::set(int index , dReal value)
		{
			_This[index] = value;
		}

		dReal DMatrix3::default::get(int i,int j)
		{
			return _This[i*4 + j];
		}
		void DMatrix3::default::set(int i,int j,dReal value)
		{
			_This[i*4 + j] = value;
		}

		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[0],dReal,M11);
		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[1],dReal,M21);
		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[2],dReal,M31);
		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[3],dReal,M41);


		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[4],dReal,M12);
		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[5],dReal,M22);
		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[6],dReal,M32);
		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[7],dReal,M42);

		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[8],dReal,M13);				
		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[9],dReal,M23);				
		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[10],dReal,M33);				
		VALUE_PROP_DEFINITION_GETSET(DMatrix3,_This[11],dReal,M43);
			
		DMatrix3^ DMatrix3::Identity::get()
		{
			DMatrix3^ d = gcnew DMatrix3();
			d->SetIdentity();
			return d;
		}
		void DMatrix3::SetIdentity()
		{
			dRSetIdentity(_This);
		}

		void DMatrix3::SetFromAxisAndAngle(dReal ax, dReal ay, dReal az, dReal angle)
		{
			dRFromAxisAndAngle(_This, ax, ay, az, angle);
		}
		void DMatrix3::SetFromAxisAndAngle(DVector3^ axis, dReal angle)
		{
			dRFromAxisAndAngle(_This, axis->X, axis->Y, axis->Z, angle);
		}
		void DMatrix3::SetFromAxisAndAngle(DVector4^ axis, dReal angle)
		{
			dRFromAxisAndAngle(_This, axis->X, axis->Y, axis->Z, angle);
		}

		DMatrix3^ DMatrix3::FromAxisAndAngle(dReal ax, dReal ay, dReal az, dReal angle)
		{
			DMatrix3^ m = gcnew DMatrix3();
			m->SetFromAxisAndAngle(ax,ay,az,angle);
			return m;
		}
		DMatrix3^ DMatrix3::FromAxisAndAngle(DVector3^ axis, dReal angle)
		{
			DMatrix3^ m = gcnew DMatrix3();
			m->SetFromAxisAndAngle(axis,angle);
			return m;
		}
		DMatrix3^ DMatrix3::FromAxisAndAngle(DVector4^ axis, dReal angle)
		{
			DMatrix3^ m = gcnew DMatrix3();
			m->SetFromAxisAndAngle(axis,angle);
			return m;
		}

		void DMatrix3::SetFromEulerAngles (dReal phi, dReal theta, dReal psi)
		{
			dRFromEulerAngles(_This, phi, theta, psi);
		}
		DMatrix3^ DMatrix3::FromEulerAngles(dReal phi, dReal theta, dReal psi)
		{
			DMatrix3^ m = gcnew DMatrix3();
			m->SetFromEulerAngles(phi, theta, psi);
			return m;
		}

		void DMatrix3::SetFrom2Axes(dReal ax, dReal ay, dReal az, dReal bx, dReal by, dReal bz)
		{
			dRFrom2Axes(_This,ax,ay,az, bx, by, bz);
		}
		void DMatrix3::SetFrom2Axes(DVector3^ a, DVector3^ b)
		{
			dRFrom2Axes(_This,a->X,a->Y,a->Z, b->X, b->Y, b->Z);
		}
		void DMatrix3::SetFrom2Axes(DVector4^ a, DVector4^ b)
		{
			dRFrom2Axes(_This,a->X,a->Y,a->Z, b->X, b->Y, b->Z);
		}

		DMatrix3^ DMatrix3::From2Axes(dReal ax, dReal ay, dReal az, dReal bx, dReal by, dReal bz)
		{
			DMatrix3^ m = gcnew DMatrix3();
			m->SetFrom2Axes(ax,ay,az, bx, by, bz);
			return m;
		}
		DMatrix3^ DMatrix3::From2Axes(DVector3^ a, DVector3^ b)
		{
			DMatrix3^ m = gcnew DMatrix3();
			m->SetFrom2Axes(a->X,a->Y,a->Z, b->X, b->Y, b->Z);
			return m;
		}
		DMatrix3^ DMatrix3::From2Axes(DVector4^ a, DVector4^ b)
		{
			DMatrix3^ m = gcnew DMatrix3();
			m->SetFrom2Axes(a->X,a->Y,a->Z, b->X, b->Y, b->Z);
			return m;
		}

		void DMatrix3::SetFromZAxis(dReal ax, dReal ay, dReal az)
		{
			dRFromZAxis(_This, ax, ay, az);
		}
		void DMatrix3::SetFromZAxis(DVector3^ a)
		{
			dRFromZAxis(_This,a->X,a->Y,a->Z);
		}
		void DMatrix3::SetFromZAxis(DVector4^ a)
		{
			dRFromZAxis(_This,a->X,a->Y,a->Z);
		}

		DMatrix3^ DMatrix3::FromZAxis(dReal ax, dReal ay, dReal az)
		{
			DMatrix3^ m = gcnew DMatrix3();
			m->SetFromZAxis(ax, ay, az);
			return m;
		}
		DMatrix3^ DMatrix3::FromZAxis(DVector3^ a)
		{
			DMatrix3^ m = gcnew DMatrix3();
			m->SetFromZAxis(a->X,a->Y,a->Z);
			return m;
		}
		DMatrix3^ DMatrix3::FromZAxis(DVector4^ a)
		{
			DMatrix3^ m = gcnew DMatrix3();
			m->SetFromZAxis(a->X,a->Y,a->Z);
			return m;
		}

		void DMatrix3::SetFromQuaternion(DQuaternion^ q)
		{
			dRfromQ(_This,q->_This);
		}
		DMatrix3^ DMatrix3::FromQuaternion(DQuaternion^ q)
		{
			DMatrix3^ m = gcnew DMatrix3();
			dRfromQ(m->_This,q->_This);
			return m;
		}

		
			void DMatrix3::SetZero()
			{
				dSetZero(_This,12);
			}
			void DMatrix3::SetValue(dReal value)
			{
				dSetValue(_This,12,value);
			}
	}
}